import axios from 'axios'



export function request1(config) {
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/v1',
    timeout: 50000
  })
  elmInstance.interceptors.request.use(config => {
    return config
  }, error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  }, error => {
    console.log(error);
  })
  return elmInstance(config)
}

export function request2(config) {
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/v2',
    timeout: 50000
  })
  elmInstance.interceptors.request.use(config => {
    return config
  }, error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  }, error => {
    console.log(error);
  })

  return elmInstance(config)
}



export function request3(config) {
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/shopping',
    timeout: 50000
  })
  elmInstance.interceptors.request.use(config => {
    return config
  }, error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  }, error => {
    console.log(error);
  })
  return elmInstance(config)
}

export function request4(config) {
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/ugc/v2/restaurants',
    timeout: 50000
  })
  elmInstance.interceptors.request.use(config => {
    return config
  }, error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  }, error => {
    console.log(error);
  })
  return elmInstance(config)
}

export function request5(config) {
  axios.defaults.withCredentials = true
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/v1/captchas',
    withCredentials: true,
    timeout: 50000,
    headers: {
      post: {
        'Accept': 'application/json',
        'Content-Type': 'application/json; charset=utf-8', 	//post请求头
      }
    },

  })
  elmInstance.interceptors.request.use(config => {
    return config
  }, error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  }, error => {
    console.log(error);
  })
  return elmInstance(config)
}

export function request6(config) {
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/v2/login',
    timeout: 50000,
    headers: {
      post: {
        'Accept': 'application/json',
        'Content-Type': 'application/json', 	//post请求头
      }
    },

  })
  elmInstance.interceptors.request.use(config => {
    return config
  }, error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  }, error => {
    console.log(error);
  })

  return elmInstance(config)
}

export function request7(config) {
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/v1/user',
  })
  elmInstance.interceptors.request.use(config => {
    return config
  }, error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  }, error => {
    console.log(error);
  })
  return elmInstance(config)
}

export function request8(config) {
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/eus/v1/users',
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    timeout: 5000,
  })
  elmInstance.interceptors.request.use(config => {
    return config
  }, error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  }, error => {
    console.log(error);
  })

  return elmInstance(config)
}

export function request9(config) {
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/promotion/v2',
    timeout: 5000
  })
  elmInstance.interceptors.request.use(config => {
    return config
  }, error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  }, error => {
    console.log(error);
  })

  return elmInstance(config)
}


export function request10(config) {
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/member/v1/users',
    timeout: 5000
  })
  elmInstance.interceptors.request.use(config => {
    return config
  }, error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  }, error => {
    console.log(error);
  })

  return elmInstance(config)
}

export function request11(config) {
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/v3'
  })
  elmInstance.interceptors.request.use(config => {
    return config
  }, error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  }, error => {
    console.log(error);
  })

  return elmInstance(config)
}



export function request12(config) {
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/v4/restaurants',
    timeout: 5000
  })
  elmInstance.interceptors.request.use(config => {
    return config
  }, error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  }, error => {
    console.log(error);
  })

  return elmInstance(config)
}

export function request13(config) {
  const elmInstance = axios.create({
    baseURL: 'http://elm.cangdu.org/bos',
    timeout: 5000
  })
  elmInstance.interceptors.request.use(config => {
    return config
  },error => {
    console.log(error);
  })
  elmInstance.interceptors.response.use(res => {
    return res.data
  },error => {
    console.log(error);
  })

  return elmInstance(config)
}